<?php
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
use yii\web\View;

/* @var $this \yii\web\View */
/* @var $content string */
AppAsset::register($this);
$this->registerJsFile('/static/js/common.js',['position'=>View::POS_BEGIN]);

?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>
    <link rel="shortcut icon" href="/favicon.ico" />
    <style>
        .cuscol{
            width:12%;
            background-color: #f8f8f8;
        }
        .active a{
            z-index: 3;
            color: white;
            cursor: default;
            background-color: #337ab7;
            border-color: #337ab7;
        }
        .newmsg{
            z-index: 3;
            color: white;
            background-color: red;
            border-color: white;
            text-align: center;
            display: inline-block;
            margin-left: 5px;
            min-width: 15px;
        }
    </style>
</head>
<body>

<?php $this->beginBody() ?>
    <div class="wrap">
        <?php
            NavBar::begin([
                'brandLabel' => '天天美',
                'brandUrl' => ['/site/index'],
                'options' => [
                    'class' => 'navbar-inverse',
                ],
            ]);
            echo Nav::widget([
                'options' => ['class' => 'navbar-nav navbar-right'],
                'items' => [
                    ['label' => '产品简介', 'url' => ['/site/product']],

                    Yii::$app->user->isGuest ?
                        ['label' => '登录', 'url' => ['weixin/login']] :
                        ['label' => '退出 (' . Yii::$app->user->identity->nickname . ')',
                            'url' => ['/weixin/logout'],
                            'linkOptions' => ['data-method' => 'post']],
                ],
            ]);
            NavBar::end();
        ?>

        <div class="container-fluid">

            <div class="row">
                <div class="col-md-2 cuscol">
                    <?= Nav::widget([
                        'id' => 'admin-stat-table',
                        'options' => ['class' => 'cusnav'],
                        'items' => [
                            [
                                'label' => '平台应用',
                                'url' => ['/agent/auth-app/'],
                                'active'=>Yii::$app->controller->id=='auth-app',
                            ],
                            [
                                'label' => '店铺管理',
                                'url' => ['/agent/auth-shop/'],
                                'active'=>Yii::$app->controller->id=='auth-shop',
                            ],
                            [
                                'label' => '订单管理',
                                'url' => ['/agent/auth-order/'],
                                'active'=>Yii::$app->controller->id=='auth-order',
                            ],
                            [
                                'label' => '返现管理',
                                'url' => ['/agent/buyer-cashback/'],
                                'active'=>Yii::$app->controller->id=='buyer-cashback',
                            ],
                            [
                                'label' => '返现设置',
                                'url' => ['/agent/buyer-qr/'],
                                'active'=>Yii::$app->controller->id=='buyer-qr',
                            ],
                            [
                                'label' => '统计',
                                'url' => ['/agent/stat-auth-account/'],
                            ],
                        ],
                    ]); ?>


                </div>
                <div class="col-md-10">
                    <?= Breadcrumbs::widget([
                        'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
                    ]) ?>
                    <?= $content ?>
                </div>
            </div>
        </div>

    </div>

    <footer class="footer">
        <div class="container">
            <p class="pull-left">&copy;  <?=Yii::$app->name."&nbsp;&nbsp;". date('Y') ?></p>
            <p class="pull-right">版权所属:北京昊识网络技术有限公司</p>
        </div>
    </footer>

<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
<script>
    //var uid="<?//=Yii::$app->user->id?>//";
    //let protocol = location.protocol === 'https:'?'wss':'ws';
    //ws = new WebSocket(protocol+"://"+window.location.host+"/wss?PHPSESSID=<?//=session_id()?>//");
    //ws.onopen = function() {
    //    // alert("连接成功");
    //    // ws.send('tom');
    //    // alert("给服务端发送一个字符串：tom");
    //    setInterval(function(){
    //        ws.send(JSON.stringify({paras:{uid:uid}}));
    //    },1000);
    //
    //};
    //ws.onmessage = function(e) {
    //    // console.log(e);
    //    let res = checkresult(e.data);
    //    // alert("收到服务端的消息：" + e.data);
    //    if(res.new_comment>0){
    //        // console.log($("a[href='/agent/auth-comment']").html(1));
    //        $("a[href='/agent/auth-comment']").html('评论管理<span class="newmsg">'+res.new_comment+'</span>');
    //    }
    //    if(res.new_msg>0){
    //        // console.log($("a[href='/agent/auth-message']").html(2));
    //
    //        $("a[href='/agent/auth-message']").html('私信管理<span class="newmsg">'+res.new_msg+'</span>');
    //    }
    //};
</script>
